import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';

import '../bean/bean.dart';
import '../platform_interface/av_audio_session_platform_interface.dart';

/// An implementation of [AvAudioSessionPlatform] that uses method channels.
class MethodChannelAvAudioSession extends AvAudioSessionPlatform {
  /// The method channel used to interact with the native platform.
  @visibleForTesting
  final methodChannel = const MethodChannel('av_audio_session');

  @override
  Future<String?> getPlatformVersion() async {
    final version = await methodChannel.invokeMethod<String>('getPlatformVersion');
    return version;
  }

  @override
  Future<bool> setAppleAudioConfiguration({
    required AppleAudioConfiguration configuration
  }) async{
    return await methodChannel.invokeMethod<bool>('setAppleAudioConfiguration', <String, dynamic>{
      "configuration": configuration.toMap
    })??false;
  }
}
